package com.leetcode.ask;

import java.util.HashMap;
import java.util.Map;

public class Number746 {
    public static void main(String[] args) {
        int a[] = new int[]{1,100,1,1,1,100,1,1,100,1};
        System.out.println(minCostClimbingStairs(a));

    }
    public static int minCostClimbingStairs(int[] cost) {
        if(cost.length<=1){
            return 0;
        }
        Map<Integer,Integer> dp = new HashMap<>();
        dp.put(0,cost[0]);
        dp.put(1,cost[1]);
        for(int i = 2;i<cost.length;i++){
            dp.put(i,Math.min(dp.get(i-2),dp.get(i-1))+cost[i]);
        }
        int n = cost.length;
        return Math.min(dp.get(n-1),dp.get(n-2));
    }
}
